﻿@using Telerik.Web.Mvc.UI
@model MvcFront.Models.DocumentEditModel
@{
    ViewBag.Title = "Document";
}
@Html.HiddenFor(model => model.DocumentId)
@Html.HiddenFor(model => model.Name)
@Html.HiddenFor(model => model.LastEditDate)
@Html.HiddenFor(model => model.DocumentStatusText)
@Html.HiddenFor(model => model.LastComment)
@Html.HiddenFor(model => model.AllowAttachments)
@Html.HiddenFor(model => model.AttachmentName)
@Html.HiddenFor(model => model.IsReadOnly)
<div class="display-label">@Html.LabelFor(model => model.Name)</div>
<div class="display-field">
    @Html.DisplayFor(model => model.Name)
</div>
<div class="display-label">@Html.LabelFor(model => model.LastEditDate)</div>
<div class="display-field">
    @Html.DisplayFor(model => model.LastEditDate)
</div>
<div class="display-label">@Html.LabelFor(model => model.DocumentStatusText)</div>
<div class="display-field">
    @Html.DisplayFor(model => model.DocumentStatusText)
</div>
<div class="editor-label">
    @Html.LabelFor(model => model.Files)
</div>
@if (Model.AllowAttachments)
{
    <div class="editor-field">
        @Html.DisplayTextFor(model => model.AttachmentName)
        @if (!string.IsNullOrEmpty(Model.AttachmentName))
            {
                @Html.ActionLink("Скачать", "DownloadDocAttachment", "Dictionary", new { documentId = Model.DocumentId }, new { target = "_blank" })
            }
        @if (!Model.IsReadOnly)
        {
            <br/><text>Заменить файл:</text>
            @Html.Telerik().Upload().Name("Files").Multiple(false)
        }
    </div>
}
<div class="display-label">@Html.LabelFor(model => model.LastComment)</div>
<div class="display-field">
    @Html.DisplayFor(model => model.LastComment)
</div>
<table id="FieldsTable" style="width: 100%">
    <tr>
        <th>
            Наименование
        </th>
        <th>
            Значение
        </th>
    </tr>
    @{
        for (int i = 0; i < Model.Fields.Count(); i++)
        {
        <tr>
            <td>@Model.Fields[i].FieldName
            </td>
            <td>@Html.EditorFor(x => x.Fields[i])
            </td>
        </tr>
        }
    }
</table>
